package jianzhiOffer;
//剑指 Offer 46. 把数字翻译成字符串
public class Num46_translateNum {
    public int translateNum(int num) {
        char[]ch = String.valueOf(num).toCharArray();//转为字符数组
        int len = ch.length;
        int []dp = new int[len + 1];
        dp[0] = 1;
        dp[1] = 1;
        for (int i = 2; i <= len; i++) {
            int n = (ch[i - 2] - '0') * 10 + (ch[i - 1] - '0');
            if (n >= 10 && n <= 25){
                dp[i] = dp[i - 1] + dp[i - 2];
            }else {
                dp[i] = dp[i - 1];
            }
        }
        return dp[len];

    }
}
